<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      请输入年龄<input type="text" v-model.number="age" />
      <ul>
        <li v-for="item in newPerson" :key="item.id">
            {{item.name}}---{{item.age}}
        </li>
      </ul>
    </div>
  </body>
  <script>
    Vue.config.productionTip = false; //阻止 vue 在启动时生成生产提示

    const vm = new Vue({
      el: "#app",
      data() {
        return {
          age: 0,
          person: [
            { id: "001", name: "lucy", age: 22 },
            { id: "002", name: "lili", age: 12 },
            { id: "003", name: "yuehan", age: 31 },
            { id: "004", name: "liming", age: 18 },
            { id: "005", name: "xiaowang", age: 4 },
            { id: "006", name: "zhangsan", age: 19 },
            { id: "007", name: "wangwu", age: 40 },
          ],
        };
      },
      computed: {
        newPerson() {
          return this.person.filter((item) => {
            return item.age > this.age;
          });
        },
      },
    });
  </script>
</html>
